package com.bkaka.service.impl;

import com.alibaba.druid.sql.visitor.functions.Bin;
import com.bkaka.dao.ExamUserDao;
import com.bkaka.entity.ExamUser;
import com.bkaka.service.ExamUserService;
import com.bkaka.util.code.CodeUtilService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigInteger;
import java.util.Date;

/**
 * Created by maxiaoqiang on 2018/7/18.
 */

@Service
public class ExamUserImpl implements ExamUserService {

    @Autowired
    private ExamUserDao dao;

    @Override
    public ExamUser login(ExamUser examUser) {
        System.out.println(dao.login(examUser.getUserName(), examUser.getPassword()));
        return dao.login(examUser.getUserName(), examUser.getPassword());
    }

    @Override
    public ExamUser findByUserName(String username) {
        dao.findByUserName(username);
        return dao.findByUserName(username);
    }

    @Override
    public void create(ExamUser examUser) {
        // 查询用户是否存在
        examUser.setCreateTime(new Date().getTime());
        dao.create(examUser);
    }

    @Override
    public void update(ExamUser examUser) {
        // 查询用户是否存在
        examUser.setUpdateTime(new Date().getTime());
        dao.update(examUser);
    }

    @Override
    public ExamUser findById(Integer userId) {
        return dao.findById(userId);
    }
}
